<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: discuz_block.php 27449 2012-02-01 05:32:35Z zhangguosheng $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
class collect_qqphotolist extends collect_base
{

    public static function getPageContent($url) {   
               
            //$url='http://www.phplover.cn';   
            $pagehtml= utility::DoGet($url);  
       
            $pagehtml = preg_replace("/　/",'',$pagehtml);   
            $pagehtml=iconv("GB2312","UTF-8//IGNORE",$pagehtml);
            //charset   
            if($pageinfo[charset] == '' ) {  
                preg_match('@<meta.+charset=([\w\-]+)[^>]*>@i',$pagehtml,$matches);  
                $pageinfo[charset] = trim($matches[1]);  
            }  
            //desctiption  
            preg_match('@<meta\s+name=\"*description\"*\s+content\s*=\s*([^/>]+)/*>@i',$pagehtml,$matches);  
 
            $desc = trim($matches[1]);  
            $pageinfo[description] = str_replace("\"", '',$desc);  
              
     
            preg_match('@<meta\s+name=\"*keywords\"*\s+content\s*=\s*([^/>]+)/*>@i',$pagehtml,$matches);  

            $keywords = trim($matches[1]);  
            $pageinfo[keywords] = str_replace("\"", '',$keywords);  
     
              
            preg_match("/<title>(.*)<\/title>/smUi",$pagehtml, $matches);  
            $pageinfo[title] = trim($matches[1]);  
            preg_match("/<body.*>(.*)<\/body>/smUi",$pagehtml, $matches);  


			$pagetitle = $pageinfo['title'];
			$pagetitle = explode('_', $pagetitle);
			$pageinfo['title'] = $pagetitle[0];	
			$pagehtml2= file_get_contents(preg_replace("/\.htm.*$/Uisx",".hdBigPic.js?time=0.1353018406448".rand(1000,9999),$url));
			if(strlen(trim($pagehtml2))<5000){
			$pagehtml2= file_get_contents(preg_replace("/\.htm.*$/Uisx",".hdPic.js?time=0.1353018406448".rand(1000,9999),$url));
			}
			if(preg_match("/(?<!_|'|\")GB2312|gbk/Uisx",$pagehtml2)){
				$pagehtml2=iconv("GB2312","UTF-8//IGNORE",$pagehtml2);
			}
			//$pagehtml2=g($pagehtml2);
			//echo "--".preg_replace("/\.htm.*$/Uisx",".hdBigPic.js?time=0.1353018406448".rand(1000,9999),$url)."--".$pagehtml2;

			preg_match_all("/'Name'\:'bigimgurl'\,\s*'Content'\:''\,\s*'Attributes'\:\[\]\,\s*'Children'\:\[\{'Name'\:''\,\s*'Content'\:'([^<>]*)'\,\s*'Attributes'\:\[\]\,\s*'Children'\:\[\]\}\]\}\,\{'Name'\:'cnt_article'\,\s*'Content'\:''\,\s*'Attributes'\:\[\]\,\s*'Children'\:\[\{'Name'\:''\,\s*'Content'\:'(.*)'\,\s*'/Uisx",$pagehtml2, $matches3);

			//print_r($matches3);
			for($i=0;$i<count($matches3[1]);$i++){
               $matches3[2][$i]=iconv("GB2312","UTF-8//IGNORE",$matches3[2][$i]);
			   $pageinfo['message'].="[img]".$matches3[1][$i]."[/img]\r\n".self::replaceHtmlAndJs2($matches3[2][$i])."\r\n";
			}
			//$pageinfo['message'] = addslashes( self::replaceHtmlAndJs2($matches2[1])); 
			//print_r($pageinfo);

            return $pageinfo;  
     
    }  
	
}
?>